package org.wms.minbearwcs.dao.storage.impl;

import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import org.wms.minbearwcs.dao.storage.inf.DualHeadStorageGroupDao;
import org.wms.minbearwcs.entity.Mapper.storage.dualStorage.DualHeadStorageGroupMapper;
import org.wms.minbearwcs.entity.PO.wcs.storage.dualHeadStorage.DualHeadStorageGroup;
import org.wms.minbearwcs.entity.PO.wcs.storage.dualHeadStorage.type.DualStorageType;

import java.util.List;
import java.util.stream.Collectors;

@Repository
@RequiredArgsConstructor
public class DualHeadStorageGroupDaoImpl implements DualHeadStorageGroupDao {

    private final DualHeadStorageGroupMapper mapper;



    @Override
    public List<DualHeadStorageGroup> selectByStorageTypeAndProductionLine(DualStorageType dualStorageType, String productionLine) {
        return new LambdaQueryChainWrapper<>(mapper)
                .eq(DualHeadStorageGroup::getDualStorageType,dualStorageType)
                .eq(DualHeadStorageGroup::getProductionLine,productionLine)
                .list();
    }

    @Override
    public List<String> selectGroupNamesByStorageTypeAndProductionLine(DualStorageType dualStorageType, String productionLine) {
        return new LambdaQueryChainWrapper<>(mapper)
                .eq(DualHeadStorageGroup::getDualStorageType,dualStorageType)
                .eq(DualHeadStorageGroup::getProductionLine,productionLine)
                .select(DualHeadStorageGroup::getDualHeadGroupCode)
                .list()
                .stream()
                .map(DualHeadStorageGroup::getDualHeadGroupCode)
                .collect(Collectors.toList());
    }
}
